package com.gcl.visitor;

public class VisitorDemo {
	// 银行柜台服务，以后银行新增业务，只需要新增一个类实现这个接口就可以
	interface Service {
		public void accept(Visitor visitor);
	}

	// 来办业务的人，里面可以增加权限控制等
	static class Visitor {
		public void process(Service service) {
			// 基本业务
			System.out.println("基本业务");
		}

		public void process(Saving saving) {
			// 存款
			System.out.println("存款");
		}

		public void process(Draw service) {
			// 提款
			System.out.println("提款");
		}

		public void process(Fund service) {
			// 基金
			System.out.println("基金");
		}
	}

	static class Saving implements Service {
		@Override
		public void accept(Visitor visitor) {
			// TODO Auto-generated method stub
			visitor.process(this);
		}
	}

	static class Draw implements Service {
		@Override
		public void accept(Visitor visitor) {
			// TODO Auto-generated method stub
			visitor.process(this);
		}
	}

	static class Fund implements Service {

		@Override
		public void accept(Visitor visitor) {
			// TODO Auto-generated method stub
			visitor.process(this);
		}
	}

	public static void main(String[] args) {
		Service saving = new Saving();
		Service fund = new Fund();
		Service draw = new Draw();
		
		Visitor visitor = new Visitor();
		Visitor guweiver = new Visitor();
		fund.accept(guweiver);
		saving.accept(visitor);
		fund.accept(visitor);
		draw.accept(visitor);
		
	}
}
